export default {
  namespaced: true, // 开启命名空间，调用时需指定模块名
  state: {
    userId: "111",
    username: "我们",
    token: null,
    NavActiveIndex: localStorage.getItem("NavActiveIndex") || 1,
  },
  mutations: {
    // 修改token
    setNavbarActive(state, index) {
      state.NavActiveIndex = index;
      localStorage.setItem("NavActiveIndex", index);
    },
    // // 修改用户信息
    // setUserInfo(state, info) {
    //   state.userId = info.userId;
    //   state.username = info.username;
    // },
  },
  actions: {
    // 添加导航并更新状态的 action
    navigateAndSetActive({ commit }, { path, index }) {
      commit("setNavbarActive", index);
      // 由于 action 不能直接访问路由，所以需要在组件中执行跳转
    },
  },
  getters: {},
};
